package wwl.lsf.hellospringboot.service;

import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import wwl.lsf.repository.MysqlMapper;

/**
 * @Title
 * @Author wangwenliang
 * @Date 2022/6/15
 * @Description
 */
@Service
public class MysqlService {

  @Autowired
  private MysqlMapper mysqlMapper;

  @Transactional(rollbackFor = Exception.class)
  public String testQuery() {
    List<Map<String, Object>> maps = mysqlMapper
        .executeQuerySql("select * from sys_dict where id =2");
     mysqlMapper
        .executeQuerySql("select * from sys_dict where id =3");
    return "";
  }

  @Transactional(rollbackFor = Exception.class)
  public String insert() {
    mysqlMapper
        .executeSql("insert into sys_dict (category,name,value) values ('ttkfz','ttkfz','ttkfz')");
    return "";
  }

  public String testQueryNoTransactional() {
  mysqlMapper
        .executeQuerySql("select * from sys_dict where id =4");
    mysqlMapper
        .executeQuerySql("select * from sys_dict where id =5");
    return "";
  }

}
